package com.cloud.api.domain.tsp;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cloud.api.myenum.LeaseCycleEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.cloud.core.entity.base.BaseEntity ;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author haohaibo
 * @since 2023-11-27
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("t_vehicle_tenant")
@Schema(name = "VehicleTenant", description = "租赁表")
public class VehicleTenant extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("id")
    private String id;

    @TableField("vin")
    @NotEmpty(message = "{validation.Information.vin}")
    @Size(max = 17,min = 17,message = "{validation.Information.vinSize}")
    private String vin;

    @Schema(description = "租户姓名")
    @TableField("car_owner")
    @NotEmpty(message = "{validation.Tenant.owner}")
    @Size(max = 50,message = "{validation.common.max}")
    private String carOwner;

    @Schema(description = "租户电话")
    @TableField("phone_number")
    @NotEmpty(message = "{validation.common.phone}")
    @Pattern(regexp = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$",message = "{validation.common.phoneFormat}")
    private String phoneNumber;

    @Schema(description = "开始租用日期")
    @TableField("lease_start_time")
    @NotNull(message = "{validation.Tenant.startTime}")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date leaseStartTime;

    @Schema(description = "租用周期，年，月")
    @TableField("lease_cycle")
    @NotNull(message = "{validation.Tenant.cycle}")
//    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private LeaseCycleEnum leaseCycle;

    @Schema(description = "租用周期，年，月",hidden = true)
    @TableField(exist = false)
    private String transLeaseCycle;

    @Schema(description = "租用结束日期")
    @TableField("lease_end_time")
    @NotNull(message = "{validation.Tenant.endTime}")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date leaseEndTime;

}